#include <stdio.h>
#include <string.h>

struct node
{
    char val;
    struct node *pre;
};

struct stack
{
    struct node *head;
};

int push(struct stack *s, char val)
{
    struct node temp;
    temp.val = val;
    temp.pre = s->head;
    s->head = &temp;
    return 1;
}

void pop(struct stack *s)
{
    if (s->head)
    {
        s->head = s->head->pre;
    }
}

int isEmpty(struct stack *s)
{
    return s->head == NULL ? 1 : 0;
}

void main()
{
    struct stack stk;
    stk.head = NULL;
    char *s = "()[]{}";
    for (int i = 0; i < strlen(s); i++)
    {
        if (s[i] == '(' || s[i] == '[' || s[i] == '{')
        {
            push(&stk, s[i]);
        }
        else
        {
            pop(&stk);
        }
    }
    printf("%d\n", isEmpty(&stk));
}